package com.study.studyelasticsearch.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 最佳实现，这样子静态方法和非静态方法都可以拿到，而且不用注入
 * @author 吴宇亮 on 2022/5/17 16:30
 */
@Order(0)
@Configuration
@ConfigurationProperties(prefix = "es-config") //@ConfigurationProperties推荐用 - 分隔符，不要用驼峰命名或者_
public class EsConfig {

    private static String ip;

    private static int httpPort;

    private static int tcpPort;
    /**
     * ES集群名称
     */
    private static String clusterName;
    /**
     * 是否开启嗅探
     */
    private static boolean sniff;

    public static String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        EsConfig.ip = ip;
    }

    public static int getHttpPort() {
        return httpPort;
    }

    public void setHttpPort(int httpPort) {
        EsConfig.httpPort = httpPort;
    }

    public static int getTcpPort() {
        return tcpPort;
    }

    public void setTcpPort(int tcpPort) {
        EsConfig.tcpPort = tcpPort;
    }

    public static String getClusterName() {
        return clusterName;
    }

    public void setClusterName(String clusterName) {
        EsConfig.clusterName = clusterName;
    }

    public static boolean getSniff() {
        return sniff;
    }

    public void setSniff(boolean sniff) {
        EsConfig.sniff = sniff;
    }

    @Override
    public String toString() {
        return "EsConfig{" +
                "ip='" + ip + '\'' +
                ", tcpPort=" + tcpPort +
                '}';
    }
}
